package com.example.base.net

import com.example.base.entity.*
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query

/**
 * 网络请求接口
 */
interface ApiService {
    @GET(Const.INDEX_URL)
    suspend fun getIndex():IndexEntityResult//获取首页
    @GET(Const.SEARCH_URL)
    suspend fun search(@Query("keyword")keyword:String,@Query("page")page:Int,@Query("limit")limit:Int):GoodsEntityResult
    @GET(Const.GOODS_INDEX_URL)
    suspend fun goodsIndex(@Path("type")type:Int,@Query("page")page:Int,@Query("limit")limit:Int):GoodsEntityResult
    @POST(Const.SEND_CODE_URL)
    suspend fun sendCode(@Query("phone")phone:String):SendCodeEntityResult
    @POST(Const.LOGIN_URL)
    suspend fun login(@Body body:RequestBody):LoginEntityResult

    @GET(Const.DETAIL_URL)
    suspend fun detail(@Path("id")id:Int,@Query("type")type:String):DetailEntityResult
    @POST(Const.ADDCAR_URL)
    suspend fun addCar(@Body body: RequestBody):AddCarEntityResult
    @GET(Const.GETCAR_URL)
    suspend fun getCar(@Query("isValid")isValid:String,@Query("page")page:String,@Query("limit")limit:String):CarEntityResult
    @POST(Const.UPDATECAR_URL)
    suspend fun updateCar(@Query("id")id:Int,@Query("number")number:Int):UpdateCarEntityResult
    @POST(Const.DELETECAR_URL)
    suspend fun deleteCar(@Query("ids")ids:ArrayList<Int>):DeleteCarEntityResult
    @GET(Const.CATEGORY_URL)
    suspend fun category():CategoryEntityResult
    @GET(Const.SEARCH_URL)
    suspend fun three(@Query("cid")cid:Int,@Query("page")page:Int,@Query("limit")limit:Int):GoodsEntityResult
    @GET(Const.COMMENT_GET_URL)
    suspend fun commentGet():CommentEntityResult
    @POST(Const.COMMENT_URL)
    suspend fun comment(@Body body: RequestBody,@Header("token")token:String):CommentEntityResult//token在页面登录后写死
    @GET(Const.COMMENTCHILD_GET_URL)
    suspend fun commentChildGet(@Query("rootId")rootId:Int):CommentEntityResult
    @POST(Const.PRE_ORDER_URL)
    suspend fun preOrder(@Body body:PreOrderParamEntity):PreOrderEntityResult
    @GET(Const.GET_PREORDER_URL)
    suspend fun getPreOrder(@Path("preOrderNo")preOrderNo:String):GetPreOrderEntityResult
    @POST(Const.CREATE_ORDER_URL)
    suspend fun createOrder(@Body body:CreateOrderParamEntity):CreateOrderEntityResult
    @POST(Const.PAY_URL)
    suspend fun pay(@Body body:PayParamEntity):PayEntityResult
    @GET(Const.USER_INFO_YRL)
    suspend fun userInfo():UserInfoEntityResult
    @GET(Const.ORDER_LIST_URL)
    suspend fun orderlist(@Query("type")type:String,@Query("page")page:Int,@Query("limit")limit:Int):OrderEntityResult

}